#ifndef	GRAPH_H
#define GRAPH_H

#include "qcustomplot.h"
#include "eventlabel.h"
//#include <QPainter>
//#include <QPaintEvent>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <opencv2/calib3d\calib3d.hpp>

class MyGraphPlot: public QCustomPlot
{
	Q_OBJECT



public:
	MyGraphPlot(QFrame *frame_9);
	~MyGraphPlot(){}

	void getDataFilename(QString );
	void getImageSize(int, int);
	//void configMyGraphPlot();
	void clearData();
	void realtimeData(int resolutionType, QVector<int> msecs, QVector<int> data);
	void clearGraph(int);
	void setupRealtimeDataDemo();
	void get8BitsFlag(bool);
	void calGrayScale(QString png_path, QString bmp_path);
	void calMTF(QString png_path, QString bmp_path);
	void selectMax(int window, cv::Mat corner, QList<int> &x, QList<int> &y);
	bool findMTFCenter(QList<int> x, QList<int> y);
	void calDistortion(QString png_path, QString bmp_path);
	void setMTFCellSize(double size);
	void getMTFData(QVector<double> &vx, QVector<double> &vy);
	void getSpectralResponseData(QVector<double> &vx, QVector<double> &vy);
	void getPhotoelectricResponse(QVector<double> &vx, QVector<double> &vy);

signals:
	void sendPointData(int, int, int);
	void sendGrayScale(QString);
	void sendLimitResolution(QString);
	void sendDistortion(QString);
	void sendPhotoelectricResponse(QString);
	void sendSpectralResponse(QString);
	void sendMTF(QString);
	void sendMeasureFailer();
public slots:
     void updateLine(int lineType, int mouseX1Pos, int mouseY1Pos, int mouseX2Pos, int mouseY2Pos);
	 void getPointPos(int, int );
	 void showSpectralResponse(QVector<int>, QVector<float>);
	 void showPhotoelectricResponse(QVector<float> photon, QVector<int> gray);
private:

	int row;
	int col;
	cv::Mat data;
	cv::Mat dataForShow;
	bool pngFlag;
	int point_data;
	bool bits8Flag;
	bool bitsChangeFlag;
	int timeRange;
	int x_left;
	int x_right;
	int MTFCenter_x;
	int MTFCenter_y;
	int MTFRectLength;
	int limitResolution;
	double mtfCellSize;
	QVector<double> mtfPair, mtfValue;
	QVector<double> spectralResponseLight, spectralResponseN;
	QVector<double> photoelectricResponsePhoton, photoelectricResponseGray;
};
 
#endif